<template>
  <table class="my-table">
      <thead>
        <tr>
          <slot name='header'></slot>
        </tr>
      </thead>
      <tbody>
        <tr v-for="item in data" :key="item.id">
          <!-- 插槽中的item访问不到 需要把 这里的item传过去 -->
          <slot :item='item' name='content'></slot>
        </tr>
      </tbody>
    </table>
</template>

<script>
// import MyTag from './MyTag.vue'

export default {
  props:{
    data:{
      type:Array,
      required:true
    }
  },
  data() {
    return {

    }
  }
}
</script>

<style lang='less' scope>
  .my-table {
  width: 100%;
  border-spacing: 0;
  img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    vertical-align: middle;
  }
  th {
    background: #f5f5f5;
    border-bottom: 2px solid #069;
  }
  td {
    border-bottom: 1px dashed #ccc;
  }
  td,
  th {
    text-align: center;
    padding: 10px;
    transition: all .5s;
    &.red {
      color: red;
    }
  }
  .none {
    height: 100px;
    line-height: 100px;
    color: #999;
  }
}
</style>